 <%if label == 'files'%>
      <select id="cat_<%=fid%>" class='cat_cls' name="file_category_ids[<%=i%>][]" 
        onchange="javascript:
        if (this.options[this.selectedIndex].value == '__new__') {
            name = prompt('<%="Input the new category name:".t%>', '');
            if (name && name!= 'null'){
	       this.disabled = true;
	       cats = document.getElementsByClassName('cat_cls');
	       for(i=0;i<cats.length;i++){
	          cats[i].disabled = true;
	       }
	       new Ajax.Request('/categories/create_from_msg/?i=<%=i%>&fid=<%=fid%>&label=<%=label%>&name='+ encodeURIComponent(name) +'&project_id=<%=params[:project_id]%>',{asynchronous:true, evalScripts:true});
	     } else
                this.selectedIndex = 0;
        } else {
          option_value = this.options[this.selectedIndex].value; 
	  new Ajax.Request('/categories/save_file_cat/?fid=<%=fid%>&cat=' + option_value,{asynchronous:true, evalScripts:true});
	}
    ">
      <option value=0><%="Uncategorized".t%></option>
      <%cats.each do |c|%>
        <option value=<%=c.id%><%=" selected" if c.id == cur_cat%>><%=c.name%></option>
      <%end%>
      <option value="__new__"><%="- Add a new category -".t%></option>
      </select> 
 <%else%>
      <select id="cat" name="category_id" class="categorySelect"
        onchange="javascript:
        if (this.options[this.selectedIndex].value == '__new__') {
            name = prompt('<%="Input the new category name:".t%>', '');
            if (name && name!= 'null'){
	       this.disabled = true;
	       new Ajax.Request('/categories/create_from_msg/?name='+ encodeURIComponent(name) +'&project_id=<%=params[:project_id]%>&label=<%=label%>',{asynchronous:true, evalScripts:true});
	     } else
                this.selectedIndex = 0;
        }
    ">
      <option value=0><%="Uncategorized".t%></option>
      <%cats.each do |c|%>
        <option value=<%=c.id%>
	<%=" selected" if c.id == cur_cat%>
	><%=c.name%></option>
      <%end%>
      <option value="__new__"><%="- Add a new category -".t%></option>
      </select> 
    <%end%>
